﻿/*省份切换*/
    //省份
    function Province(str)
    {
        ProvinceSendAjax("Province",str);
    }
    //省份从usershoppinginfo.aspx打开
    function Province2(str)
    {
        ProvinceSendAjax2("Province",str);
    }

    function ProvinceSendAjax(op,str)
    {
        var param = "Option="+ op +"&ProvinceId="+ str;
        var options=
        {
            method:'post',
            parameters:param,
            onComplete:
            function(transport)
            {
                var retv=transport.responseText;
                document.getElementById("Cityli").innerHTML=retv;
            }     
        }
        new  Ajax.Request('makeorders.aspx',options);
    }
    
    function ProvinceSendAjax2(op,str)
    {
        var param = "Option="+ op +"&ProvinceId="+ str;
        var options=
        {
            method:'post',
            parameters:param,
            onComplete:
            function(transport)
            {
                var retv=transport.responseText;
                document.getElementById("Cityli").innerHTML=retv;
            }     
        }
        new  Ajax.Request('usershoppinginfo.aspx',options);
    }

    //城区
    function Citys(str)
    {
        CitysSendAjax("Citys",str);
    }
    
    //城区
    function Citys2(str)
    {
        CitysSendAjax2("Citys",str);
    }

    function CitysSendAjax(op,str)
    {
        var param = "Option="+ op +"&CitysId="+ str;
        var options=
        {
            method:'post',
            parameters:param,
            onComplete:
            function(transport)
            {
                var retv=transport.responseText;
                document.getElementById("City2li").innerHTML=retv;
            }     
        }
        new  Ajax.Request('makeorders.aspx',options);
    }
    
    function CitysSendAjax2(op,str)
    {
        var param = "Option="+ op +"&CitysId="+ str;
        var options=
        {
            method:'post',
            parameters:param,
            onComplete:
            function(transport)
            {
                var retv=transport.responseText;
                document.getElementById("City2li").innerHTML=retv;
            }     
        }
        new  Ajax.Request('usershoppinginfo.aspx',options);
    }

/*** 开始  修改人：YM 修改时间：2010-04-21 表单验证***/
function checkOrders()
{
    //收货人信息
    if(document.getElementById("isFillConsignedata").value!="1")
    {
       alert("温馨提示：您必须完整收货人信息！");
       return false;
    }
    //支付方式paymentMethod
	var paymentMethod = document.getElementsByName("paymentMethod");
	var isPaymentMethodChecked=false;
	if(paymentMethod)
	{
	    for (var j = 0; j < paymentMethod.length; j++)
		{
			if (paymentMethod[j].checked)
			{
			    isPaymentMethodChecked=true;
			}
		}
	}
	if(!isPaymentMethodChecked)
	{
		alert("温馨提示：您必须选定一个支付方式！");
		return false;
	}
	
	//配送方式DeliveryModeTable
	var deliveryModeTable = document.getElementsByName("DeliveryMode");
	var isDeliveryMethodChecked=false;
	if(deliveryModeTable)
	{
	    for (var j = 0; j < deliveryModeTable.length; j++)
		{
			if (deliveryModeTable[j].checked)
			{
			    isDeliveryMethodChecked=true;
			}
		}
	}
	if(!isDeliveryMethodChecked)
	{
		alert("温馨提示：您必须选定一个配送方式！");
		return false;
	}
}


function PointCost(point,costType) {
    if (document.getElementById("productTotalPrice")) {
        var freightTotalPrice = document.getElementById("freightTotalPrice").value;
        var feeTotalPrice = document.getElementById("FeeTotalPrice").value;
        var hidPointTotal = document.getElementById("hidPoint").value;
        var productPrice = document.getElementById("productTotalPrice").value;
        var info = "商品总价: ￥" + productPrice + "元";
        var totalPrice = parseFloat(productPrice);
        if (costType == "freight") {
            freightTotalPrice = point;
        }
        else if (costType == "fee") {
            feeTotalPrice = point;
        }
        else if (costType == "point") {
            var totalPoint = document.getElementById("totalPoint").value;
            var test = document.getElementById("hidMaxPoint");
            var maxTotalPoint = parseInt(document.getElementById("hidMaxPoint").value);
            if (parseInt(totalPoint) >= 0 && parseInt(totalPoint) <= maxTotalPoint) {
                hidPointTotal = parseInt(totalPoint);
            }
            else if (parseInt(totalPoint) > maxTotalPoint) {
                document.getElementById("errorMsg").innerHTML = "使用点券数量超出最大使用点券";
                hidPointTotal = maxTotalPoint;
                document.getElementById("totalPoint").value = maxTotalPoint;
            }
        }
        if (freightTotalPrice != "") {
            totalPrice = totalPrice + parseFloat(freightTotalPrice);
            document.getElementById("freightTotalPrice").value = freightTotalPrice;
            info = info + " + " + "配送费用: ￥" + freightTotalPrice + "元";
        } 
        if (feeTotalPrice != "") {
            totalPrice = totalPrice + parseFloat(feeTotalPrice);
            document.getElementById("FeeTotalPrice").value = feeTotalPrice;
            info = info + " + " + "手续费: ￥" + feeTotalPrice + "元";
        }
        if (hidPointTotal != "") {
            totalPrice = totalPrice - parseFloat(hidPointTotal);
            document.getElementById("hidPoint").value = hidPointTotal;
            info = info + " - " + "使用点券: ￥" + hidPointTotal + "元";
        }

        document.getElementById("TotalCostMoney").innerHTML = totalPrice;
        document.getElementById("TotalPriceInfo").innerHTML = info;
    }
}

/*** 结束  修改人：YM 修改时间：2010-04-21 表单验证***/